package com.spzx.order.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.RemoteOrderService;
import com.spzx.order.api.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
@Slf4j
public class RemoteOrderFallbackFactory  implements FallbackFactory<RemoteOrderService> {

    @Override
    public RemoteOrderService create(Throwable cause) {
        log.error("订单服务调用失败:{}", cause.getMessage());
        return new RemoteOrderService() {

            @Override
            public R<OrderInfo> getOrderInfoByOrderNo(String orderNo) {
                return  R.fail("获取订单数据失败:" + cause.getMessage());
            }
        };
    }
}
